jQuery(document).ready(function(){
	jQuery.fn.validate = function(type) {
		var field = jQuery(this);
		var fieldVal = jQuery(this).val();
		switch(type){
			case 'email':
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				return fieldVal != '' && emailReg.test(fieldVal);
			case 'required':
				switch(field[0].nodeName.toLowerCase()){
					case 'input':
						switch(field.attr('type')){
							case 'password':
							case 'text':
								return fieldVal != '';
							case 'checkbox':
								return field.is(':checked');
						}
						break;
					case 'select':
						var selected = jQuery(this).children('option:selected');
						return selected.length() > 0;
						break;
					case 'textarea':
						return field.val() != '';
					default:
						return true;
				}
				break;
			default:
				return true;
		}
	}
});